package com.example.tg.Service.Impl;

import com.example.tg.Dao.SupplierMapper;
import com.example.tg.Service.SupplierService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Supplier;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;
    @Override
    public int addSp(Supplier supplier) {
        return supplierMapper.addSp(supplier);
    }

    @Override
    public int deleSp(int id) {
        return supplierMapper.deleSp(id);
    }

    @Override
    public int updaSp(Supplier supplier) {
        return supplierMapper.updaSp(supplier);
    }

    @Override
    public PageInfo listSp(String name,int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Supplier> list =supplierMapper.listSp(name);
        PageInfo<Supplier> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int contSp() {
        return supplierMapper.contSp();
    }


    @Override
    public List nameSp() {
        return supplierMapper.nameSp();
    }

    @Override
    public Supplier showSp( Integer id) {
        return supplierMapper.showSp(id);
    }

    @Override
    public Supplier showSp2(String name) {
        return supplierMapper.showSp2(name);
    }
}
